Ext.define('AM.view.modules.westMenu.WestPanelScope', {
    extend: 'Ext.panel.Panel',
    alias: 'widget.westPanelScope',
    
    bodyStyle: {
        "overflow-x": 'hidden',
        "overflow-y": "auto"
    },
    
    initComponent: function(){
        this.callParent(arguments);
    },
    title: modules_lang.memuTitle,
    collapsible: true,
    buildMenu: function(roleCode, deptID){
		var me = this;
		var showMsg = "";
		/*
		 Ext.Ajax.request({
				url: showMsgUrl,
	        	//url: 'workbench/orchid/data/modules.jsons',
	            params: {
	            	
	            },
	            success: function(response){
	            	 var data = response.responseText;
	                 var jsonData = Ext.decode(data, true);
	                 showMsg = jsonData.data.msg1;
	                 
	            }
	        });
        */
		Ext.Ajax.request({
 			url: findMenuUrl,
//          url: 'findMenu.json',
      	//url: 'workbench/orchid/data/modules.jsons',
          params: {
              roleCode: roleCode,
              deptID: deptID
          },
          success: function(response){
              var data = response.responseText;
              var jsonData = Ext.decode(data, true);
              // 使用模板生成
             	var tpl = new Ext.XTemplate(
             			'<div class="subNav" id="subNav">',
             			/*
             			'<div class="showMsg">',
             				'<span onclick="clickLi(\'31001013\',\'提醒管理\',\'PJ.view.remindmanagement.List\',event)" style="line-height:2.3; padding:0px 13px 0px 13px;font-weight: bold;font-size: 13px;cursor: pointer;">提醒 ('+showMsg+' )</span>',
             				'<span onclick="clickLi(\'31001012\',\'消息管理\',\'PJ.view.messagemanagement.Frame\',event)" style="font-weight: bold;font-size: 13px;cursor: pointer;">消息('+showMsg+')</span>',
             			'</div>',
             			*/
      				'<tpl for=".">',
      					'<dl id="dl_{resourceID}" >',
      						'<dt onclick="clickDiv(\'{resourceID}\')" style="cursor:pointer;" ><span class="title"><b class="{iconCls}"></b>{resourceName}</span><b id="div_b_{resourceID}" class="expandIcon"></b></dt>',
      						'<tpl for="children">',
      							'<dd style="display:none;cursor:pointer;" onmouseover="overLi(\'{resourceID}\');" onmouseout="outLi(\'{resourceID}\');"  onclick="clickLi(\'{resourceID}\',\'{resourceName}\',\'{url}\',event)" id="li_{resourceID}"><span class="title"><b class="{iconCls}"></b>{resourceName}</span></dd>',
      						'</tpl>',
      					'</dl>',
                      '</tpl>',
      				'</div>');
//				'<div class="leftColumn" id="leftColumn">',
//				'<tpl for=".">',
//				'<div class="nav" style="cursor: pointer;" onclick="clickDiv(\'{resourceID}\')">{resourceName}<b id="div_b_{resourceID}" class="shrinkIco"></b></div>',
//					'<ul id="ul_{resourceID}" style="display:none;" class="subnav">',
//						'<tpl for="children">',
//						'<li style="cursor: pointer;" onclick="clickLi(\'{resourceID}\',\'{resourceName}\',\'{url}\',event)" id="li_{resourceID}">{resourceName}</li>',
//						'</tpl>',
//					'</ul>',
//              '</tpl>',
//				'</div>'); 
              tpl.overwrite(me.body, jsonData);
              //删除菜单上的加号
//              $('#div_b_8a10e7f5614f5aa401614f6b52460001').remove();
              //删除菜单原本的点击事件
//              $('#dl_8a10e7f5614f5aa401614f6b52460001').children('dt').removeAttr('onclick');
              //给菜单“学员维护”添加点击事件，当点击的时候跳转到uum后台。
//              $('#dl_8a10e7f5614f5aa401614f6b52460001').click(function(){
//            	  if(!$('#tiao')[0]){
//                	  var url=location.protocol+'//'+location.hostname+'/uum';
//                	  var yuansu="<a id='tiao' href="+url+" target='_blank'></a>";
//                	  $(this).append(yuansu);
//            	  }
//            	  $('#tiao')[0].click();
////            	  window.open(url,'_blank');
//            	  /*var win = Ext.create("Ext.window.Window", {
//            		    id: "myWin",
//            		    title: "学员维护",
//            		    width: 962,
//            		    height: 650,
//            		    modal: true,
//            		    maximizable: true,
//            		    layout: "fit",
//            		    autoShow: true,
//            		    html: '<iframe style="overflow:auto;width:100%; height:100%;" src='+url+' frameborder="0"></iframe>'
//            		});*/
//        	  });
              // ajax异步请求当前登陆人的权限
              Ext.Ajax.request({
					url: findUserPermissionsUrl,
//                  url: 'findUserPermissions.json',
					//url: "workbench/orchid/data/permissions.jsons",
                  success: function(response){
                      var data = response.responseText;
                      var json = Ext.decode(data, true);
                      if (json.success) {
                          var cp = Ext.create('Ext.state.CookieProvider');
                          Ext.state.Manager.setProvider(cp);
                          cp.set("permissions", json.data);
                      }
                  }
              });
          }
      });
    }
});
